package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.constant.CommonConstant;
import com.hl.sfzy.entity.SysBooking;

import com.hl.sfzy.mapper.SysBookingMapper;
import com.hl.sfzy.service.SysBookingService;

import com.hl.sfzy.entity.SysCompany;
import com.hl.sfzy.entity.SysIntegral;
import com.hl.sfzy.mapper.SysBookingMapper;
import com.hl.sfzy.mapper.SysIntegralMapper;
import com.hl.sfzy.service.SysBookingService;
import com.hl.sfzy.service.SysIntegralService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("sysBookingService")
public class SysBookingServiceImpl implements SysBookingService {
    @Autowired
    private SysBookingMapper sysBookingMapper;


    @Override
    public int add(SysBooking entity) {
        return sysBookingMapper.insert(entity);
    }

    @Override
    public int edit(SysBooking entity) {
        return sysBookingMapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return sysBookingMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return sysBookingMapper.deleteBatch(ids);
    }

    @Override
    public List<SysBooking> find(SysBooking entity) {
        return sysBookingMapper.select(entity);
    }

    @Override
    public SysBooking findById(Integer id) {
        return null;
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, SysBooking entity) {
        //开启分页
        PageHelper.startPage(pageNum, pageSize);
        //当前页数据
        List<SysBooking> list = sysBookingMapper.select(entity);
        //分页信息对象
        PageInfo<SysBooking> pageInfo = new PageInfo<>(list);

        Map<String, Object> map = new HashMap<>();

        //map存储当前页数据、总页数、总记录数
        map.put(CommonConstant.PAGE_LIST,list);
        map.put(CommonConstant.PAGE_TOTAL,pageInfo.getPages());
        map.put(CommonConstant.TOTAL,pageInfo.getTotal());

        return map;
    }

    @Override
    public List<SysBooking> findByStatus(Integer status) {
        return sysBookingMapper.selectByStatus(status);
    }


//通过状态查询
}
